package hc.bre.data

import hc.bre.cmn.IDetailList
import hc.bre.cmn.ListOption
import hc.bre.cmn.RuleDefinition
import hc.bre.cmn.RuleScriptBuilder
import hc.bre.policy.CategoryDefinition
import hc.bre.policy.CategoryOption
import java.lang.reflect.ParameterizedType

@groovy.transform.CompileStatic
@groovy.transform.ToString(includeNames=true, includePackage = false)
class DataDefinition<T extends ListOption> extends RuleDefinition implements IDetailList<T> {
	List<T> list=[];
	@Override
	public DataDefinition load(Map map) {
		super.load(map);
		list = hc.Util.loadList(map['list'], realClass())
		return this;
	}

	Class<T> realClass() {
		ParameterizedType pt = (ParameterizedType) this.getClass().getGenericSuperclass();
		return (Class<T>) pt.getActualTypeArguments()[0];
	}
}
